<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title></title>  
    <link rel="stylesheet" href="../css/pintuer.css">
    <link rel="stylesheet" href="../css/admin.css">
    <script src="../js/jquery.js"></script>
    <script src="../js/pintuer.js"></script>  
    <script src="../js/jqPaginator.min.js"></script>  
    <script src="../js/layer/layer.js"></script>
</head>
<body>
<form method="post" action="">
  <div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 专家列表</strong></div>
    <div class="padding border-bottom">
      <ul class="search" >
         <li style="float: right;padding-right: 3%;">
          <input type="text" placeholder="请输入微信ID"  class="input" style="width:250px; line-height:17px;display:inline-block"  id="wechatId"/>
          <a href="javascript:void(0)" class="button border-main icon-search" id="submit"> 搜索</a>
        </li>
          <li style="float: right;">
            <select name="cid" class="input" style="width:200px; line-height:17px;" id="expertType">
				<option value="">请选择专家类型</option>
              	  <c:forEach items="${ExpertType }" var="type">
					<option value="${type.id }">${type.issueTypeName }</option>
				  </c:forEach>
            </select>
          </li>
      </ul>
    </div>
    <table class="table table-hover text-center">
      <tr>
      	<th>ID</th>      
        <th>微信</th>
        <th>姓名</th>
		<th>性别</th>
        <th>电话</th>
        <th>工作单位</th>
        <th>职务</th>
		<th>专长</th>
        <th>专家类型</th>
        <th>点赞</th>
		<th>倒赞</th>
		<th>收入</th>
		<th>详情</th>
		<th>状态</th>
		<th>创建时间</th>
        <th width="100">操作</th>       
      </tr>      
       <tbody id="content">
       		
       </tbody>
      <tr>
        <td colspan="24">
        	<div class="pagelist">
                <ul class="pagination" id="pagination">
				</ul>
				<input id="totalCount" type="hidden" value="${pageUtil.getTotalCount() }"/>
			    <input id="pageSize" type="hidden" value="10"/>
				<input id="currentPage" type="hidden" value="${pageUtil.getCurPage() }" />
				<select id="rank" style="padding:5px 15px; border:1px solid #ddd;">
					<option value="desc">降序</option>
					<option value="asc">升序</option>
				</select>
         	</div>
         </td>
      </tr>
    </table>
  </div>
</form>
<script type="text/javascript">

function audit(id){
	layer.confirm('审核结果', {
		  btn: ['通过','驳回'] //按钮
		}, function(){
			window.location.href="${ctx }/expert/updateStatus?auditStatus=1&expertId="+id;
		}, function(){
			layer.prompt({title: '驳回理由', formType: 2}, function(text, index){
			    //layer.msg(text);
				window.location.href="${ctx }/expert/updateStatus?auditStatus=3&expertId="+id+"&message="+ encodeURI(encodeURI(text));
			  });
		});
	
	//window.location.href="${ctx }/expert/updateStatus?auditStatus=1&expertId="+id;
}
function pause(id){
	if(confirm("您确定要暂停专家吗?")){
		window.location.href="${ctx }/expert/updateStatus?auditStatus=2&expertId="+id;
	}
}
function start(id){
	if(confirm("您确定要启用吗?")){
		window.location.href="${ctx }/expert/updateStatus?auditStatus=1&expertId="+id;
	}
}
//单个删除
/*function del(){
	if(confirm("您确定要删除问题吗?")){
		
	}
}*/
</script>
 <script type="text/javascript">
	$(function(){
		function page(){
			var totalCount=parseInt($("#totalCount").val());
			var pageSize=parseInt($("#pageSize").val());
			var currentPage=parseInt($("#currentPage").val());
			$('#pagination').jqPaginator({
				totalCounts: totalCount,
	            currentPage: currentPage,
	            pageSize: pageSize,
	            visiblePages: 7,
				first: '<a href="javascript:void(0);">首页</a>',
				prev: '<a href="javascript:void(0);"><i class="arrow arrow2"></i>上一页</a>',
				next: '<a href="javascript:void(0);">下一页<i class="arrow arrow3"></i></a>',
				last: '<a href="javascript:void(0);">末页</a>',
				page: '<a href="javascript:void(0);">{{page}}</a>',
				onPageChange: function (num) {
					
					var wechatId=$("#wechatId").val();
					var expertType=$("#expertType").val();
					var rank=$("#rank").val();
					var url="${ctx }/expert/findAll";
					$.post(url,{"curPage":num,"wechatId":wechatId,"expertType":expertType,"rank":rank},callback,"json");
					function callback(data){
						
						   var json=eval(data);
						   var content=json.content;
						   $("#content").html("");
						   for(var i=0;i<content.length;i++){
							   
							   var rowContent = "<tr>"
								    + "<td>"
                                    + content[i].id
                                    + "</td>"
                                    + "<td>"
                                    + content[i].userEntity.wechatId
                                    + "</td>"
                                    + "<td>"
                                    + content[i].name
                                    + "</td>"
									 + "<td>"
                                    + content[i].sex
                                    + "</td>"
                                    + "<td>"
                                    + content[i].phone
                                    + "</td>"
                                    + "<td>"
                                    + content[i].workUnit
                                    + "</td>"
                                    + "<td>"
                                    + content[i].duty
                                    + "</td>"
									 + "<td>"
                                    + content[i].speciality
                                    + "</td>"
                                    + "<td>"
                                    + content[i].expertType
                                    + "</td>"
                                    + "<td>"
                                    + content[i].likeCount
                                    + "</td>"
                                    + "<td>"
                                    + content[i].dislikeCount
                                    + "</td>"
                                    + "<td>"
                                    + content[i].rewardAmount
                                    + "</td>"
                                    + "<td> <a href='${ctx}/expert/findInfo?expertId="+content[i].id+"' style='color:#09c;'>专家详情</a>"
                                    + "</td>"
                                    + "<td id='status"+content[i].id+"'>"
                                    + content[i].auditStatus
                                    + "</td>"
                                    + "<td>"
                                    + content[i].dateFormat
                                    + "</td>"
                                    + "<td><div class='button-group' id='auditStatus"+content[i].id+"'> </div>"
                                    + "</td>"
                                    + "</tr>";
							   $("#content").append(rowContent);
							   var auditStatus = $("#auditStatus"+content[i].id);
							   if(content[i].auditStatus=='1'){
								   $("#status"+content[i].id).html("<font color='green'>正常</font>");
								   auditStatus.append("<a class='button border-red' href='javascript:void(0)' onclick='return pause("+content[i].id+")'><span class='icon-ban'></span> 停用</a>");
							   }else if(content[i].auditStatus=='2'){
								   $("#status"+content[i].id).html("<font color='red'>停用</font>");
								   auditStatus.append("<a class='button border-main' href='javascript:void(0)' onclick='return start("+content[i].id+")''><span class='icon-check-circle-o'></span> 启用</a>");
							   }else if(content[i].auditStatus=='0'){
								   $("#status"+content[i].id).html("<font color='red'>未审核</font>");
								   auditStatus.append("<a class='button border-main' href='javascript:void(0)' onclick='return audit("+content[i].id+")''><span class='icon-check'></span> 审核</a>");
							   }else if(content[i].auditStatus=='3'){
								   $("#status"+content[i].id).html("<font color='#f39800'>已驳回</font>");
								   auditStatus.append("<a class='button border-main' href='javascript:void(0)' onclick='return audit("+content[i].id+")''><span class='icon-check'></span> 审核</a>");
							   }
						   }
					}			
				}
			});
		}
		
		$("#submit").click(function(){
			page();
		});
		
		page(); 
	  
		$("#rank").change(function(){
			page();
		});
	})
  </script>
</body></html>